package com.greensam.pixelengine.event.disruptor;

import com.greensam.pixelengine.event.base.TypeEvent;
import com.greensam.pixelengine.event.base.TypeEventListener;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 平台总线事件监听器
 *
 * @author Ma Chengrui
 * @since 2025/10/13 17:40
 */
public class AggregateTypeEventListener<T extends TypeEvent> implements TypeEventListener<T> {

    private final Map<String, TypeEventListener<T>> baseEventListeners = new LinkedHashMap<>();

    public void addEventListener(TypeEventListener<T> listener) {
        baseEventListeners.put(listener.getId(), listener);
    }

    @Override
    public void onEvent(T pixelEvent) {
        baseEventListeners.values().forEach(listener -> listener.onEvent(pixelEvent));
    }

}
